package com.cai.io.demo;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectOutputDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("user.obj");

        ObjectOutputStream oos = new ObjectOutputStream(fos);

        Person p = new Person("张三",12);
        oos.writeObject(p);
        oos.close();
    }
}
